﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ComponentModel;
using NTTDATA.BEENChina.ResultCertification.Config;
using NTTDATA.BEENChina.ResultCertification.PropertyGridUtil;

namespace NTTDATA.BEENChina.ResultCertification.Checker.Date
{
    [Serializable]
    [VerfityAttribute(Id = "VerfityRq0213", Name = "两行且非指定付笺", CategoryType = EnumCategoryType.日期, Model = true)]
    public class VerfityRq0213 : VerfityOneResult
    {
        private string _comment = "22";
        
        [Category("指定付笺"), Description("输入指定付笺值")]
        [EditorAttribute(typeof(PropertyGridRichText), typeof(System.Drawing.Design.UITypeEditor))]
        public string Comment
        {
            get { return _comment; }
            set { _comment = value; }
        }

        public override bool CheckResult(List<List<string>> result, string entryCommon)
        {
            bool bresult = false;
            if (result == null || result.Count() < 2)
            {
                return false;
            }

            int entryRowCount = 0;
            for (int i = 0; i < 2; i++)
            {
             
                if( !IsEmptyRow(result[i]) )
                {
                    entryRowCount++;
                    
                }
            }

            bresult = (entryRowCount>1) && entryCommon != Comment;

            if (bresult)
            {
                System.Console.WriteLine("VerfityRq0213");
            }

            return bresult;
        }


        private bool IsEmptyRow(List<string> row)
        {
            if (row == null)
            {
                return true;
            }

            return row.All(colStr => colStr.Replace("\\", "").Replace("/", "") == string.Empty);
        }

    }
}
